<?php namespace Admin\Controller;
use Hdphp\Controller\Controller;
//定义品牌类
class BrandController extends CommonController{
	private $model;
	public function __init(){
		parent::init();
		//实例化模型
		$this->model=new \Common\Model\Brand;
	}
	public function index(){
		$data=$this->model->get();
		View::with('data',$data);
//		p($data);
		View::make();
	}
	public function add(){
		if(IS_POST){
			//添加品牌
			if(!$this->model->store()) View::error($this->model->getError());
			View::success('添加成功',U('index'));
		}
		View::make();
	}
	//编辑
	public function edit(){
		if(IS_POST){
			if(!$this->model->edit()) View::error($this->model->getError());
			View::success('编辑成功',U('index'));
		}
		$data=$this->model->where("bid=".Q('get.bid',0,'intval'))->find();
		p($data);
		View::with('data',$data);
		
		View::make();
	}
	//删除
	public function del(){
		$this->model->where("bid=".Q('get.bid',0,'intval'))->delete();
		View::success('删除成功',U('index'));
	}
	
}






 ?>